﻿/********************************************************************************
 * This code is provided as-is, with no explicit or implicit guaranties         *
 * and is governed by the Common Creative License.                              *
 *                                                                              *
 * If you find this code useful and decide to use it for your                   *
 * own proyects, please be sure to copy this complete header, along             *
 * with the authors name.                                                       *
 *                                                                              *
 * A link back from your personal site to the articles URL                      *
 * will also be appreciated                                                     *
 *                                                                              *
 * @author: Matthias Reichenbach                                                *
 * (http://www.codeproject.com/script/Membership/Profiles.aspx?mid=3576642)     *
 *                                                                              *
 * ******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FuzzyLogic
{
    class TagakiSugenoFuzzyRule
    {
        List<string> ifvalues;
        double crispResult;
        Variable[] vars;

        public TagakiSugenoFuzzyRule(double crispResult, string[] ifvalues)//, Variable[] vars)
        {
            this.crispResult = crispResult;
            this.ifvalues = new List<string>();
            this.ifvalues.AddRange(ifvalues);
            //this.vars = vars;
        }

        public void addIfValue(string value)
        {
            ifvalues.Add(value);
        }

        public double getWeight(FuzzySet[] set)
        {
            double res = 1;
            int i = 0;
            foreach (string ifvalue in ifvalues)
            {
                res *= set[i].getMembership(ifvalue);
                i++;
            }
            return res;
        }

        public double CrispOutput { get { return crispResult;} }
    }
}
